import { Injectable } from '@angular/core';
import { Headers, Http, RequestOptions } from '@angular/http';
import 'rxjs/add/operator/toPromise';
import { SafeUrlPipe } from '../pipe/safeUrl.pipe';
import {Observable} from "rxjs/Observable";

@Injectable()
export class SystemInfoService {
  serv= 'service';
  file;
  url;

  private sysinfosubUrl = 'http://192.168.9.123:3000/upload_config/';
  private host = 'http://192.168.9.123:3000';

 // url: string = './images/data.txt';

    constructor(private http: Http) { }

  getdata() {
      console.log('你点击了，我返回后台所有数据给你')
    this.http.get(this.sysinfosubUrl).subscribe(function (data) {
      console.log(data);

    });
  }







/*  getsystemConfig(): Observable<any[]> {
    return this.http
      .get(this.sysinfosubUrl + '/terminal_info ')
      .map(res => {return res.json() });
  }*/

/*
  getsysVersion(){
      return this.http.get(this.host + '/upload_config');

  }
  getsysplatform(){
    return this.http.get(this.host + '/upload_config');

  }
*/


  getfilepic(e) {
 console.log('我这边是上传图片的');

    let file = e.target.files[0];
    let url = window.URL.createObjectURL(file);
    this.file = file;
    this.url = url;
    console.log(e.target.files);
    console.log(url);
    console.log(file);

  }


/*  getsubdata( picurl, version, platform) {
      console.log(picurl + ':' + version + ':' + platform)
  let headers = new Headers({'Content-Type': 'application/json'});
  let options = new RequestOptions({ headers: headers});
 this.http.post(this.sysinfosubUrl , { file: picurl , product: version , version : platform }, options).subscribe(function (data) {
      console.log(data);

    });
    console.log( 'e8888888 ');

  }*/
  getsubdata( formdata) {
    console.log(formdata)
    let headers = new Headers({
      "Accept": "application/json"
    });
    let options = new RequestOptions({ headers: headers});
    this.http.post(this.sysinfosubUrl , formdata, options).subscribe(function (data) {
      console.log(data);
    });

  }


}
